﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="KSGJ.Index" %>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="X-UA-Compatible" content="ie=9;ie=8" />
    <title>快速改价</title>
    <script src="/ksgj/Scripts/jquery.min.js" type="text/javascript"></script>
    <script src="/ksgj/Scripts/jquery.loadthumb.js" type="text/javascript"></script>
    <script src="/ksgj/Scripts/AlertBox/jquery.artDialog.js?skin=blue" type="text/javascript"></script>
    <link href="/ksgj/css/MainSet.css" rel="stylesheet" type="text/css" />
    <link href="/ksgj/css/Header_Nav.css" rel="stylesheet" type="text/css" />
    <link href="/ksgj/css/sidebar.css" rel="stylesheet" type="text/css" />
    <link href="/ksgj/css/From_Effect.css" rel="stylesheet" type="text/css" />
    <link href="/ksgj/css/btn.css" rel="stylesheet" type="text/css" />

<%--    <script src="/Scripts/jquery.min.js" type="text/javascript"></script>
    <script src="/Scripts/jquery.loadthumb.js" type="text/javascript"></script>
    <script src="/Scripts/AlertBox/jquery.artDialog.js?skin=blue" type="text/javascript"></script>
    <link href="/css/MainSet.css" rel="stylesheet" type="text/css" />
    <link href="/css/Header_Nav.css" rel="stylesheet" type="text/css" />
    <link href="/css/sidebar.css" rel="stylesheet" type="text/css" />
    <link href="/css/From_Effect.css" rel="stylesheet" type="text/css" />
    <link href="/css/btn.css" rel="stylesheet" type="text/css" />--%>

    <style type="text/css" media="screen">
        #AspNetPager a{text-decoration:none;}
        a{text-decoration:none;}
        a:hover{text-decoration:none;}
        .close-meerkat {
			position: absolute;
			display: block;
			height: 18px;
			width: 18px;
			background: url('/ksgj/img/close-x.png') no-repeat 0 0;
			cursor: pointer;
			text-indent: -9000px;
			z-index: 10;
			bottom:10px;
			right:10px;
		}
		#meerkat-wrap
		{
		    right:0;
		}
    </style>
    <script language="javascript" type="text/javascript">
        $(document).ready(function () {
            $.dialog({
                id: 'msg',
                title: '公告',
                content: '<div style="font-size:14px;line-height:20px;">尊敬的用户，您好！本次版本升级的内容为：更新了操作界面、改进了核心算法，程序响应更迅速、新增对全网用户设置优惠的功能！并设置了子账户版本，您的子账户也可以使用本应用的所有功能( 您在使用中对新的改动有任何问题、意见或建议，都可以马上联系我们的旺旺<a target="_blank" href="http://amos.im.alisoft.com/msg.aw?v=2&uid=%E6%AD%A6%E6%B1%89%E5%8D%93%E5%A4%A9%E7%A7%91%E6%8A%80%E6%9C%89%E9%99%90%E5%85%AC%E5%8F%B8&site=cntaobao&s=1&charset=utf-8" ><img border="0" style="vertical-align:middle;" src="http://amos.im.alisoft.com/online.aw?v=2&uid=%E6%AD%A6%E6%B1%89%E5%8D%93%E5%A4%A9%E7%A7%91%E6%8A%80%E6%9C%89%E9%99%90%E5%85%AC%E5%8F%B8&site=cntaobao&s=1&charset=utf-8" alt="我要提意见！" /></a>)同时为了给每一位客户提供更好，更周到的服务。</div><div style="position:absolute;right:10px;border-bottom:40px;">--快速改价运营团队<br />--2011年12月07日</div>',
                width: 320,
                height: 240,
                left: '100%',
                top: '100%',
                fixed: true,
                drag: false,
                padding: '10px',
                resize: false
            })
        });
        function resizeImg() {
            var imgcount = $(".imgdiv img").length;
            for (var i = 0; i < imgcount; i++) {
                $($(".imgdiv img")[i]).loadthumb({
                    "src": $(".imgdiv img")[i].src,
                    "imgId": $(".imgdiv img")[i].id,
                    "parentId": $($(".imgdiv img")[i]).parent()[0].id
                });
            }
        }
        function onloadfun() {
            $("#AspNetPager a[disabled|=disabled]").addClass("paginate_button_disabled");
            $("a.btn").wrapInner("<span></span>");
            $("a.btn, button, .pager img").hover(function () {
                $(this).stop().fadeTo(200, 0.7);}, function () {
                $(this).stop().fadeTo(200, 1.0);
            });
            $("ul.gallery li").hover(function () {
                $(this).css("border-color", "#E6C26E");
                $(this).css("box-shadow", "0 0 2px #E6C26E");
            }, function () {
                $(this).css("border-color", "#c0c0c0");
                $(this).css("box-shadow", "0 0 2px rgba(0,0,0,0.25)");
            });
        }
        function delovertag() {
            var deltagdialog = $.dialog({ title: '正在清除...', lock: true, opacity: 0.7, width: 400, height: 168, esc: false });
            $.ajax({
                type: "post",
                url: "/ksgj/AjaxCommand/clearAlltag.ashx",
                //url: "/AjaxCommand/clearAlltag.ashx",
                beforeSend: function (XMLHttpRequest) {
                    $("a.aui_close").hide();
                    deltagdialog.content("<h3 style='color:#205A94'>正在清除过期优惠,请稍后...<img src='img/loading.gif' alt='' /></h3><p style='color:#205A94'>清除时间与您宝贝数量相关，宝贝越多耗费时间越长。</p><p style='color:#205A94'>请不要刷新或关闭页面，耐心等候!</p>");
                },
                success: function (data, textStatus, jqXHR) {
                    deltagdialog.title("清除过期人群");
                    deltagdialog.content("<p style='color:#205A94'>"+ data +"</p>");
                    deltagdialog.size(400, 94);
                    deltagdialog.button({ name: '确定', focus: true });
                },
                complete: function (XMLHttpRequest, textStatus) {
                    $("a.aui_close").show();
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    deltagdialog.title("清除失败");
                    deltagdialog.content("<p style='color:#205A94'>清除失败，请稍后再试!</p>");
                    deltagdialog.size(400, 94);
                    deltagdialog.button({ name: '确定', focus: true });
                }
            });
        }

        function copyfunc(obj) {
            var goodnid = $(obj).parent().siblings(".goodcontent").eq(0).children("input:hidden").val();
            var dialog = $.dialog({ title: '复制宝贝地址',lock: true,opacity: 0.7,width: 390 });
            $.ajax({
                type: "post",
                url: "/ksgj/AjaxCommand/getgoodurl.ashx",
                //url: "/AjaxCommand/getgoodurl.ashx",
                data: {
                    goodid: goodnid
                },
                beforeSend: function (XMLHttpRequest) {
                },
                success: function (data, textStatus, jqXHR) {
                    dialog.content(data);
                },
                complete: function (XMLHttpRequest, textStatus) {
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    // 通常 textStatus 和 errorThrown 之中
                    // 只有一个会包含信息
                    //alert(XMLHttpRequest); // 调用本次AJAX请求时传递的options参数
                    dialog.content("复制宝贝链接出错，请稍后再试");
                }
            });
        }

        function gaijiafunc(obj) {
            var goodnid = $(obj).parent().siblings(".goodcontent").eq(0).children("input:hidden").val();
            var pricetobody = $(obj).parent().siblings(".goodcontent").eq(2).children("input:text").eq(0).val();
            var gaijiaprice = $(obj).parent().siblings(".goodcontent").eq(2).children("input:text").eq(1).val();
            var priceovertime = $(obj).parent().siblings(".goodcontent").eq(2).children("input:text").eq(2).val();
            var newprice = $(obj).parent().siblings(".goodcontent").eq(1).children("span").eq(1).text()
            var qizhe = accMul($(obj).parent().siblings(".goodcontent").eq(1).children("span").eq(0).text(), 0.7);
            var re = /^[1-9]+[0-9]*]*$/;
            var remoney = /^(([0-9]+\.[0-9]{2})|([0-9]*[1-9][0-9]*))$/;
            var maxmoney = $("#maxmoney").val() - 0;

            if (pricetobody == "") {
                msgalet("请选择或填写改价对象!");
                return;
            }
            if (newprice < 0) {
                msgalet("优惠价格不能大于原价!");
                return;
            }
            else if (newprice == "NaN") {
                msgalet("优惠价格只能填写数字!");
                return;
            }
            else if (!remoney.test(newprice)) {
                msgalet("优惠价格只能填写保留2位的数字!比如:8.95");
                return;
            }
            else if (newprice == "" || gaijiaprice == "") {
                msgalet("请输入优惠价格!");
                return;
            }
            else if (gaijiaprice == 0) {
                msgalet("优惠价格不能为0!");
                return;
            }
            else if (newprice < qizhe) {
                msgalet("由于淘宝网优惠价格规定，优惠后价格不能低于原价的70%(" + qizhe + ")");
                return;
            }
            else if (maxmoney >= 0) {
                if (gaijiaprice > maxmoney) {
                    msgalet("您的最大优惠金额是" + maxmoney + "元");
                    return;
                }
            }
            if (priceovertime == "") {
                msgalet("请输入过期时间!");
                return;
            }
            if (!re.test(priceovertime)) {
                msgalet("过期时间只能输入以分钟为单位的整数!");
                return;
            }
            if (priceovertime > 30) {
                msgalet("过期时间不能大于30分钟!");
                return;
            }
            var gaijiadialog = $.dialog({ title: '正在修改...', lock: true,opacity:0.7, width: 400,height: 150,esc:false });
            $.ajax({
                type: "post",
                url: "/ksgj/AjaxCommand/setPriceQuick.ashx",
                //url: "/AjaxCommand/setPriceQuick.ashx",
                data: {
                    price: gaijiaprice,
                    changeto: pricetobody,
                    goodid: goodnid,
                    overtime: priceovertime
                },
                beforeSend: function (XMLHttpRequest) {
                    $("a.aui_close").hide();
                    gaijiadialog.content("<h3 style='color:#205A94'>正在改价,请稍后...<img src='img/loading.gif' alt='' /></h3><p style='color:#205A94'>请不要刷新或关闭页面!</p>");
                },
                success: function (data, textStatus, jqXHR) {
                    if (data == "ok") {
                        gaijiadialog.title("改价成功");
                        gaijiadialog.content("<h3 style='color:#205A94'>改价成功!</h3>");
                        gaijiadialog.size(400, 94);
                        gaijiadialog.button({ name: '确定', focus: true });
                    }
                    else {
                        gaijiadialog.title("改价失败");
                        gaijiadialog.content("<p style='color:#205A94'>" + data + "</p>");
                        gaijiadialog.size(400, 94);
                        gaijiadialog.button({ name: '确定',focus: true });
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {
                    $("a.aui_close").show();
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    // 通常 textStatus 和 errorThrown 之中
                    // 只有一个会包含信息
                    //alert(XMLHttpRequest); // 调用本次AJAX请求时传递的options参数
                    gaijiadialog.title("改价失败");
                    gaijiadialog.content("<p style='color:#205A94'>改价失败，请稍后再试！</p>");
                    gaijiadialog.size(400, 94);
                    gaijiadialog.button({ name: '确定', focus: true });
                }
            });
        }

        function accSubtr(arg1, arg2) {
            var r1, r2, m, n;
            try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 }
            try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 }
            m = Math.pow(10, Math.max(r1, r2));
            //动态控制精度长度
            n = (r1 >= r2) ? r1 : r2;
            return ((arg1 * m - arg2 * m) / m).toFixed(n);
        }
        function accMul(arg1, arg2) {
            var m = 0, s1 = arg1.toString(), s2 = arg2.toString();
            try { m += s1.split(".")[1].length } catch (e) { }
            try { m += s2.split(".")[1].length } catch (e) { }
            return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m)
        }
        function getnewprice(obj) {
            var oldprice = $(obj).parent().siblings(".goodcontent").eq(1).children("span").eq(0).text();
            $(obj).parent().siblings(".goodcontent").eq(1).children("span").eq(1).text(accSubtr(oldprice, $(obj).val()));
//            $(obj).keyup(function () {
//                var oldprice = $(obj).parent().siblings(".goodcontent").eq(1).children("span").eq(0).text();
//                $(obj).parent().siblings(".goodcontent").eq(1).children("span").eq(1).text(accSubtr(oldprice, $(obj).val()));
//            });
        }

        function searchgood() {
            if ($("#keyword").val() == "") {
                msgalet("请输入查询宝贝的标题");
                return false;
            }
            else {
                return true;
            }
        }

        function changepriceto(obj) {
            $(obj).parent().siblings(".goodcontent").eq(1).children("input").eq(0).val($(obj).val());
        }

        function msgalet(contstr) {
            $.dialog({
                id:'msgdialog',
                content: contstr,
                icon:'warning',
                init: function () {
                    var that = this, i = 3;
                    var fn = function () {
                        that.title("提示(" + i + '秒后关闭)');
                        !i && that.close();
                        i--;
                    };
                    timer = setInterval(fn, 1000);
                    fn();
                },
                close: function () {
                    clearInterval(timer);
                }
            });
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:HiddenField ID="maxmoney" runat="server" Value="-10" />
        <div id="height-wrapper">
            <div>
                <div id="header_toolbar">
                    <div class="container_12">
                        <h1>
                            <span>快速改价</span>&nbsp;&nbsp;&nbsp;&nbsp;
			                <span><a style="color:#CCC" href="http://bangpai.taobao.com/group/thread/14509393-268697663.htm" title="帮助" target="_blank">需要帮助点我吧</a></span>
                            <span style="font-size:14px;float:right;">
                                请使用以下浏览器获得最佳浏览效果:
                                <a target="_blank" title="谷歌浏览器" href="http://www.google.cn/chrome/intl/zh-CN/landing_chrome.html?hl=zh_cn&brand=CHMA&utm_campaign=zh_cn&utm_source=zh_cn-ha-apac-zh_cn-bk&utm_medium=ha">
                                    <img src="img/browsers/Chrome.png" alt="chrome" class="browsersimg" />
                                </a>
                                <a target="_blank" title="遨游3浏览器" href="http://www.maxthon.cn/mx3/">
                                    <img src="img/browsers/Maxthon.png" alt="maxthon" class="browsersimg" />
                                </a>
                                <a target="_blank" title="火狐浏览器" href="http://firefox.com.cn/download/">
                                    <img src="img/browsers/Firefox.png" alt="firefox" class="browsersimg" />
                                </a>
                                <a target="_blank" title="IE8浏览器" href="http://windows.microsoft.com/zh-CN/internet-explorer/downloads/ie-8">
                                    <img src="img/browsers/IE.png" alt="ie" class="browsersimg" />
                                </a>
                                <a target="_blank" title="腾讯TT浏览器" href="http://tt.qq.com/">
                                    <img src="img/browsers/Traveler.png" alt="traveler" class="browsersimg" />
                                </a>
                                <a target="_blank" title="360极速浏览器" href="http://chrome.360.cn/">
                                    <img src="img/browsers/360jisu.png" alt="traveler" class="browsersimg" />
                                </a>
                            </span>
                        </h1>
                    </div>
                </div>
                <nav id="header_main">
                    <div class="container_12">
                        <ul id="nav_main">
                            <li class="current">
                                <a href="Index.aspx">
                                    <img src="img/icons/25x25/blue/computer-imac.png" width="25" height="25" alt="" />
                                    单人改价
                                </a>
                                <ul>
                                    <li>
                                        <span>针对单个买家快速修改商品价格，修改后的价格只对您指定的买家生效.</span>
                                    </li>
                                </ul>
                            </li>
                            <li>
                                <a href="allindex.aspx">
                                    <img src="img/icons/25x25/blue/blocks---images.png" width="25" height="25" alt="" />
                                    全网折扣
                                </a>
                            </li>
                        </ul>
                    </div>
                </nav>
                <div id="nav_sub"></div>
            </div>
            <div class="container_12">
                <asp:UpdatePanel ID="contentwrapper" runat="server">
                    <ContentTemplate>
                        <div id="aside">
                            <div id="sidebar_top">
                                <div class="userinfo"> 
                                    <div class="info"> 
                                        <div class="avatar"> 
                                            <img src="img/sprites/userinfo/avatar.png" width="80" height="80" alt=""> 
                                        </div> 
                                        <a href="order.htm">我要续费</a> 
                                    </div> 
                                    <ul class="links"> 
                                        <li> 
                                            <strong>
                                                <asp:Label ID="username" runat="server" Text=""></asp:Label>
                                            </strong> 
                                        </li> 
                                        <li> 
                                            <asp:LinkButton ID="closewindow" runat="server" onclick="closewindow_Click" OnClientClick="return confirm('是否需要退出[快速改价]?');">退出</asp:LinkButton>
                                        </li> 
                                        <li> 
                                            <a href="javascript:return false;" onclick="delovertag()">清除过期人群</a> 
                                        </li>
                                    </ul> 
                                    <div class="clearfix">
                                    </div>
                                </div>
                            </div>
                            <div id="sidebar_content" >
                                <asp:TreeView ID="cateTree" runat="server" style="margin:20px auto;" 
                                    NodeIndent="20" ShowExpandCollapse="true" class="sidetree" ExpandDepth="1" 
                                    ForeColor="#4D4D4D" onselectednodechanged="cateTree_SelectedNodeChanged">
                                    <SelectedNodeStyle Font-Underline="False" ForeColor="White" 
                                        HorizontalPadding="0px" VerticalPadding="0px" BackColor="#375B91" />
                                </asp:TreeView>
                            </div>
                        </div>
                        <div id="main_content">
                            <div class="box" style="position:relative;margin:0;">
                                <div class="header">
                                    <img src="img/icons/16x16/list.png" width="16" height="16" alt="" />
                                    <h3>宝贝列表</h3>
                                </div>
                                <div class="content"></div>
                                <div style="position:absolute;top:7px;right:5px;">
                                    <asp:TextBox ID="keyword" runat="server" Width="200px" MaxLength="40" style="float:none;display:inline;margin:0"></asp:TextBox>
                                    <asp:LinkButton ID="search" runat="server" onclick="search_Click" OnClientClick="return searchgood();" CssClass="btn blue" style="vertical-align:bottom">搜索</asp:LinkButton>
                                </div>
                            </div>
                            <div class="grid_12">
                                <ul class="gallery" style="margin:0 0 10px 0;">
                                    <asp:Repeater ID="goodlist" runat="server" 
                                        onitemdatabound="goodlist_ItemDataBound">
                                        <ItemTemplate>
                                            <li style="width:630px;">
                                                <div class="imgdiv" id="imgdiv<%# Eval("numiid") %>">
                                                    <img id="<%# Eval("numiid") %>" src="<%# Eval("picurl") %>" alt="" style="display:none" />
                                                </div>
                                                <div style="float:left;width:505px;">
                                                    <div class="goodcontent">
                                                        <%# Eval("title").ToString().Trim()%>
                                                        <asp:HiddenField ID="Hiddennid" runat="server" Value='<%# Eval("numiid") %>' />
                                                    </div>
                                                    <div class="goodcontent">
                                                        价格：￥<span><%# Eval("price")%></span>&nbsp;&nbsp;&nbsp;优惠后价格：￥<span><%# Eval("price")%></span>&nbsp;&nbsp;&nbsp;
                                                        选择改价对象：<asp:DropDownList ID="chatter" onchange="changepriceto(this);" runat="server" style="width:100px;"></asp:DropDownList>
                                                    </div>
                                                    <div class="goodcontent" style="font-size:12px;">
                                                        改价对象：<input type="text" class="_25" style="float:none;margin:0;" />
                                                        优惠价格：<input type="text" class="_25" onkeyup="getnewprice(this)" style="float:none;margin:0;width:90px" />
                                                        过期时间：<input type="text" class="_25" style="float:none;margin:0;width:50px" value="10" />分钟  
                                                    </div>
                                                    <div class="goodcontent" style="text-align:right;">
                                                        <a class="btn blue" onclick="gaijiafunc(this)">快速改价</a>
                                                        <a class="btn blue" onclick="copyfunc(this)">复制宝贝地址</a>
                                                    </div>
                                                </div>
                                            </li>
                                        </ItemTemplate>
                                        <FooterTemplate>
                                            <asp:Label ID="footlabel" runat="server" Text="此类目没有宝贝！" CssClass="nocount" Visible='<%# goodlist.Items.Count == 0 %>'></asp:Label>
                                        </FooterTemplate>
                                    </asp:Repeater>
                                </ul>
                            </div>
                            <div class="grid_12">
                                <webdiyer:aspnetpager id="AspNetPager" runat="server" HorizontalAlign="Center"
                        Width="100%" CustomInfoHTML="共%PageCount%页，当前为第%CurrentPageIndex%页" CustomInfoTextAlign="Left" 
                        Direction="LeftToRight" FirstPageText="首页" LastPageText="尾页" LayoutType="Div" 
                        NextPageText="下一页" PageIndexBoxType="TextBox" PrevPageText="上一页" 
                        ShowPageIndexBox="Never" PageSize="7" ShowNavigationToolTip="True" 
                        EnableTheming="False" NumericButtonCount="6" 
                            CurrentPageButtonPosition="Center" UrlPageIndexName="currpage" 
                            Wrap="False" CurrentPageButtonClass="paginate_active" UrlPaging="False" 
                                    AlwaysShow="True" 
                                    FirstLastButtonsClass="first paginate_button" 
                                    PagingButtonsClass="paginate_button" 
                                    PrevNextButtonsClass="previous paginate_button" 
                                    onpagechanging="AspNetPager_PageChanging"></webdiyer:aspnetpager>
                            </div>
                        </div>
                    </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="cateTree" EventName="SelectedNodeChanged" />
                        <asp:AsyncPostBackTrigger ControlID="AspNetPager" EventName="PageChanging" />
                        <asp:AsyncPostBackTrigger ControlID="closewindow" EventName="Click" />
                        <asp:AsyncPostBackTrigger ControlID="search" EventName="Click" />
                    </Triggers>
            </asp:UpdatePanel>
            </div>
        </div>
        
        <div id="footer">
            <div class="container_12">
                <span>© 2010-2011武汉卓天信息科技有限公司版权所有</span>&nbsp;&nbsp;&nbsp;
                <span>
                    客服旺旺:&nbsp;<a target="_blank" href="http://amos.im.alisoft.com/msg.aw?v=2&uid=%E6%AD%A6%E6%B1%89%E5%8D%93%E5%A4%A9%E7%A7%91%E6%8A%80%E6%9C%89%E9%99%90%E5%85%AC%E5%8F%B8&site=cntaobao&s=1&charset=utf-8" ><img border="0" style="vertical-align:middle;" src="http://amos.im.alisoft.com/online.aw?v=2&uid=%E6%AD%A6%E6%B1%89%E5%8D%93%E5%A4%A9%E7%A7%91%E6%8A%80%E6%9C%89%E9%99%90%E5%85%AC%E5%8F%B8&site=cntaobao&s=1&charset=utf-8" alt="有问必答" /></a>
                </span>
                <span>
                    客服邮箱:&nbsp;<span>ex_sky@163.com</span>
                </span>
                <span>
                    客服电话:&nbsp;<span>027-82420526</span>&nbsp;<span>18971460801</span>
                </span>
                <span>
                    <a href="http://bangpai.taobao.com/group/14509393.htm" target="_blank">进入帮派</a>
                </span>
            </div>
        </div>
    </form>
    <%--<script type="text/javascript" src="http://toptrace.taobao.com/assets/getAppKey.js" topappkey="12310450" defer="defer"></script>--%>
</body>
</html>
